// const permissionMenuMap = new Map([[
//   'configer:manual:dwell', ['驻留控制']
// ], [
//   'configer:manual:senior', ['特殊控制']
// ], [
//   'configer:manual:base', ['方案选择']
// ], [
//   'configer:manual:optimize', ['其他']
// ]])
const permissionControlMap = new Map([[
  'configer:manual:dwell', [4, 22, 25]
], [
  'configer:manual:senior', [1, 2, 3]
], [
  'configer:manual:base', [5, 6, 9, 10, 12, 19]
], [
  'configer:manual:optimize', [23, 100, 24]
], [
  'configer:manual:dwell:step', [4]
], [
  'configer:manual:dwell:stage', [4]
], [
  'configer:manual:dwell:phaselock', [22]
], [
  'configer:manual:dwell:directionlock', [25]
], [
  'configer:manual:senior:yellowfalsh', [1]
], [
  'configer:manual:senior:allred', [2]
], [
  'configer:manual:senior:close', [3]
], [
  'configer:manual:base:fix', [5]
], [
  'configer:manual:base:free', [6]
], [
  'configer:manual:base:adapter', [9]
], [
  'configer:manual:base:coordinate', [10]
], [
  'configer:manual:base:ped', [12]
], [
  'configer:manual:base:pedfree', [19]
], [
  'configer:manual:optimize:procedure', [23]
], [
  'configer:manual:optimize:temp', [100]
], [
  'configer:manual:optimize:preempt', [24]
]])

export function getPermissionMenu (thirdPartyControl) {
  // 按第三方平台角色的权限处理可显示的手动控制菜单
  // let thirdPartyControlMenu = []
  // for (let i = 0; i < permissionList.length; i++) {
  //   let per = permissionList[i].permission_code
  //   if (permissionMenuMap.get(per)) {
  //     thirdPartyControlMenu = thirdPartyControlMenu.concat(permissionMenuMap.get(per))
  //   }
  // }
  // console.log(thirdPartyControlMenu)
  // return thirdPartyControlMenu
  let thirdPartyControlMenu = []
  for (let i = 0; i < thirdPartyControl.length; i++) {
    let control = thirdPartyControl[i]
    if ([4, 22, 25].indexOf(control) !== -1) {
      thirdPartyControlMenu = thirdPartyControlMenu.concat(['residentcontrol'])
    }
    if ([1, 2, 3].indexOf(control) !== -1) {
      thirdPartyControlMenu = thirdPartyControlMenu.concat(['specialcontrol'])
    }
    if ([5, 6, 9, 10, 12, 19].indexOf(control) !== -1) {
      thirdPartyControlMenu = thirdPartyControlMenu.concat(['schemeselection'])
    }
    if ([23, 24, 100].indexOf(control) !== -1) {
      thirdPartyControlMenu = thirdPartyControlMenu.concat(['others'])
    }
  }
  thirdPartyControlMenu = [...new Set(thirdPartyControlMenu)]
  // console.log(thirdPartyControlMenu)
  return thirdPartyControlMenu
}

export function getPermissionControl (permissionList) {
  // 按第三方平台角色的权限处理可显示的手动控制按钮
  let thirdPartyControl = []
  for (let i = 0; i < permissionList.length; i++) {
    let per = permissionList[i].permission_code
    if (permissionControlMap.get(per)) {
      thirdPartyControl = thirdPartyControl.concat(permissionControlMap.get(per))
    }
  }
  // console.log(thirdPartyControl)
  return thirdPartyControl
}
